home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9872 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: charnel.ecst.csuchico.edu!sjonni
  2. From: sjonni@ecst.csuchico.edu (Sigurjon Fridsonsson)
  3. Newsgroups: comp.lang.c++,alt.winsock
  4. Subject: Help! The MVC++ CSocket class
  5. Date: 4 Mar 1996 22:40:36 GMT
  6. Organization: California State University, Chico
  7. Message-ID: <4hfrh4$kc3@charnel.ecst.csuchico.edu>
  8. NNTP-Posting-Host: guzzler.ecst.csuchico.edu
  9.  
  10. Newsgroups: comp.lang.c++,alt.winsock
  11. Subject: Help! The CSocket class in MVC++4.0
  12. Summary: 
  13. Followup-To: 
  14. Distribution: 
  15. Organization: California State University, Chico
  16. Keywords: 
  17. Cc: 
  18.  
  19. Help!
  20.  
  21. I'm trying to use MFC's CSocket class to send a simple echo request and 
  22. then read the responce.  The following is a stripped down version of my 
  23. code (in MVC++4.0).  Can anyone tell my what I'm doing wrong.  
  24. I can send the request but never get a responce!
  25.  
  26. All comments will be appreciated.
  27.  
  28. Thanks,  Sjonni
  29.  
  30. sjonni@ecst.csuchico.edu
  31.  
  32. ----------------------------8><-----------CUT HERE ------------------
  33.  
  34.     CSocket* sock;
  35.     BYTE buffer[50];
  36.     int err;
  37.     
  38.     if (!AfxSocketInit())
  39.         return;
  40.     
  41.     sock = new CNetmSocket();
  42.  
  43.     err = sock->Create(0,SOCK_DGRAM);
  44.     err = sock->SendTo("echodataechodata",16,IPPORT_ECHO,"111.22.33.4",0);
  45.     if( err < 0 )      
  46.         err = sock->GetLastError();
  47.  
  48.     Sleep(1000);
  49.  
  50.     err = sock->Receive(buffer,50);
  51.     if( err < 0 )
  52.         err = sock->GetLastError();
  53.  
  54.     delete sock;
  55.     sock = NULL;  
  56.     return; 
  57.  
  58.